#ifndef _SPU_CELLCSP_H_
#define _SPU_CELLCSP_H_

#include <csp_protocol_msg.h>
#include <csp_shared_types.h>
#include <csp_macros.h>

#include <stdint.h>
#include <malloc_align.h>

#ifdef __cplusplus
extern "C" {
#endif

	typedef char* csp_process;
	typedef csp_channel_t* csp_channel;
	typedef csp_guard_list_t* csp_guard_list;


	csp_process csp_create_process(char *mnemonic);

	int csp_run_process(csp_process process);
	int csp_run_parallel(csp_process procs[], size_t);


	csp_guard_list csp_create_guards(csp_channel chans[], size_t size);
	csp_channel csp_create_channel(int chan_type, uint64_t chan_id, size_t nbytes);

	int csp_channel_read(csp_channel chan, void *addr);
	int csp_channel_write(csp_channel chan, void *addr);

	void csp_poison_channel(csp_channel chan);

	int csp_alt_select(csp_guard_list guards, void *inputs[], size_t n_inputs);

	void csp_exit_network();
	void csp_yield();
	void csp_exit(int val);
	int csp_spe_id();
	int csp_pid();
	size_t csp_code_size();
	ea_addr_t csp_shared_addr();

	void csp_timing_start();
	void csp_timing_stop();
/*
	int csp_chan_write(int chan_type, uint64_t chan_id, void *addr, size_t nbytes);
	int csp_chan_read(int chan_type, uint64_t chan_id, void *addr, size_t nbytes);
*/

#ifdef __cplusplus

	int __csp_parallel(int size, char *mnemonics[]);

}
/*
class CSPProcess{
	private:
		char* _mnemonic;
	public:
		CSPProcess(char *mnemonic){_mnemonic = mnemonic;}
		int Run(){
			char* ar[] = {_mnemonic};
			return __csp_parallel(1, ar);
		}
};
#include <stdarg.h>
class Parallel{
	private:
		void Init(int s, char **m){
			mnemonics = m;
			size = s;
		}
		char **mnemonics;
		int size;
	public:
		//Parallel(char *arg1, ... ){}
		Parallel(int size, char **m){Init(size, m);}
		int Run(){
			return __csp_parallel(size, mnemonics);
		}
};



class Channel {
	private:
		long id;
		long type;
	public:
		Channel(long _type, long _id){id=_id; type=_type;}
		void Write(void* data, size_t size){csp_chan_write(type, id, data, size);}
		template <typename T>
			void Write(T *t){Write(t, sizeof(T));}
		void Read(void* data, size_t size){csp_chan_read(type, id, data, size);}
		template <typename T>
			void Read(T *t){Read( t, sizeof(T));}
};
*/
#endif // __cplusplus


#endif
